package com.zygh.policeasset.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zygh.policeasset.mapper.WitbigMapper;
import com.zygh.policeasset.pojo.Witbig;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/service/WitbigService.class */
public class WitbigService {
    @Autowired
    WitbigMapper witbigMapper;

    public List<Witbig> findAll(String type) {
        return this.witbigMapper.findAll(type);
    }

    public PageInfo listFindAll(String type, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo<>(this.witbigMapper.findAll(type));
    }

    public Integer add(Witbig params) {
        List<Witbig> witbigList = this.witbigMapper.findAll(params.getType());
        if (witbigList.size() != 0) {
            int num = Integer.parseInt(witbigList.get(witbigList.size() - 1).getWitbigNum());
            StringBuffer witbigNum = new StringBuffer();
            for (int i = 0; i < 2 - String.valueOf(num + 1).length(); i++) {
                witbigNum.append("0");
            }
            witbigNum.append(num + 1);
            params.setWitbigNum(witbigNum.toString());
        } else {
            params.setWitbigNum("01");
        }
        return Integer.valueOf(this.witbigMapper.add(params));
    }

    public Integer update(Witbig params) {
        return Integer.valueOf(this.witbigMapper.updateById(params));
    }

    public Integer remove(int id) {
        return Integer.valueOf(this.witbigMapper.deleteById(Integer.valueOf(id)));
    }

    public String findOneByName(String type, String witbigName) {
        return this.witbigMapper.findOneByName(type, witbigName);
    }

    public Witbig findById(Integer id) {
        return this.witbigMapper.findById(id);
    }
}